home *** CD-ROM | disk | FTP | other *** search
/ Compute! Gazette 1998 Special / special1988a.d64 / math dungeon (.txt) < prev    next >
Commodore BASIC  |  2022-09-20  |  10KB  |  295 lines

  1. 110 dim cm$(22),cm(22),in$(5),in(5),ob$(13),ob(13),ds$(40),fl(10,10)
  2. 120 sys65517:cc=peek(781)
  3. 130 ifcc=40thenpoke53281,1
  4. 150 gosub 700:gosub1620
  5. 155 print"[147]"
  6. 160 gosub790:cm(2)=1:cm(5)=1:fori=14to19:cm(i)=1:next:ob(1)=1
  7. 170 pr$=ds$(1):gosub2570:ifgtthenpr$=ds$(2):gosub2570
  8. 180 ifgt=0thenpr$=ds$(3):gosub2570
  9. 190 gosub2310:ifpl=2orpl=5thengosub800:goto190
  10. 200 ifpl=16andgt=0thenpr$=ds$(3):gosub2570:goto190
  11. 210 ifpl=16then280
  12. 220 ifpl>16thengoto250
  13. 230 goto170
  14. 240 print"[147]":pr$=ds$(4):gosub2570
  15. 250 gosub790:fori=14to19:cm(i)=1:next:gosub2310:ifpl=16then280
  16. 260 ifpl=15thenpr$=ds$(4):gosub2570
  17. 270 goto250
  18. 280 gosub790:print"[147]":cm(1)=1:cm(3)=1:cm(6)=1:fori=14to19:cm(i)=1:next
  19. 290 cm(4)=1
  20. 300 pr$=ds$(5):gosub2570:ifmb=0thenpr$=ds$(6):gosub2570
  21. 310 ifmbthenpr$=ds$(7):cm(7)=1:gosub2570:ifnt=1thenpr$=ds$(11):gosub 2570
  22. 320 iffd=0thenpr$=ds$(8):nt=1:gosub2570
  23. 330 iffdthenpr$=ds$(9):nt=0:gosub2570
  24. 340 gosub2310:ifpl=15then300
  25. 350 if(pl=18)or(pl=19)thengoto300
  26. 360 ifpl=17thengoto160
  27. 370 if(pl=16)and(fd=0)then320
  28. 380 ifpl=16andfd=0then320
  29. 390 ifpl=16then450
  30. 400 ifpl=1thenpr$=ds$(10):gosub2570
  31. 410 if(pl=3)or(pl=6)thengosub900:goto340
  32. 415 ifpl=7andnt=0thenprint"i see no note here!":goto340
  33. 420 ifpl<>7then340
  34. 430 pr$="there is a question on the note.":gosub2570
  35. 435 gosub1320:ifwr=1thengoto160
  36. 440 pr$=ds$(12):gosub2570:pr$=ds$(13):gosub2570:fd=1:mb=0:goto340
  37. 450 gosub790:print"[147]";
  38. 470 pr$="a trap door opens beneath your feet and you begin sliding down a "
  39. 480 pr$=pr$+"chute. you pass a neon sign that says :":gosub2570:print
  40. 490 ifcc=40then505
  41. 500 print"    'math dungeon'":print:print"      'level "+str$(lv)+"'"
  42. 501 print:print:goto510
  43. 505 print"           'math dungeon'"
  44. 506 print:print"             'level "+str$(lv)+"'"
  45. 510 pr$="press any key to continue":gosub2570:print:print
  46. 520 geta$:ifa$=""then520
  47. 530 lt=1:px=int(rnd(1)*10)+1:py=int(rnd(1)*10)+1:fl(py,px)=2
  48. 540 gosub790:cm(9)=1:fori=12to19:cm(i)=1:next:cm(9)=lt:cm(22)=1
  49. 550 iffl(py,px)=2thenprint"[147]":pr$=ds$(14):gosub2570
  50. 560 iffl(py,px)=1thenprint"[147]":pr$=ds$(15):gosub2570
  51. 570 iflt=1thenpr$=ds$(16):gosub2570
  52. 580 gosub2310
  53. 590 ifpl=9thengosub950:goto580
  54. 600 ifpl=12thengosub970:goto580
  55. 610 ifpl=13thengosub1000:goto580
  56. 620 ifpl=15andlo=0then550
  57. 630 ifpl=15andlo=1thengosub1020:goto570
  58. 640 ifpl=14then580
  59. 650 ifpl=22thengosub2470:goto670
  60. 660 ifpl>15thengosub1560:if(lo=0)or(wa=1)then580
  61. 670 onzgosub1860,1860,2000
  62. 680 goto670
  63. 690 end
  64. 700 print"[147]":ifcc=40thenprinttab(10);:goto720
  65. 710 printtab(1);
  66. 720 print"    math dungeon   ":print"":ifcc=40thenprinttab(12);:goto740
  67. 730 printtab(3);
  68. 740 print"a math adventure"
  69. 750 print"":ifcc=40then755
  70. 751 print"   enter desired          level(1-5)";:goto760
  71. 755 print"   enter desired level(1-5)";
  72. 760 inputlv:iflv<1orlv>5thengoto750
  73. 770 fori=1to22:readcm$(i):next:fori=1to5:readin$(i):next
  74. 780 fori=1to29:readds$(i):next:return
  75. 790 fori=1to22:cm(i)=0:nexti:ifin(5)=1thencm(20)=1:return
  76. 800 ifpl=2andgt=1thenpr$="the gate is already open.":gosub2570
  77. 810 ifpl=2andgt=0thengt=1:print"ok."
  78. 820 ifpl=5andgt=0thenpr$="the gate is already closed.":gosub2570
  79. 830 ifpl=5andgt=1thengt=0:print"ok."
  80. 840 return
  81. 850 ifpl=1andfd=1thenpr$="the door is already open.":gosub2570
  82. 860 ifpl=1andfd=0thenfd=1:print"ok."
  83. 870 ifpl=4andfd=0thenpr$="the door is already closed.":gosub2570
  84. 880 ifpl=4andfd=1thenfd=0:print"ok."
  85. 890 return
  86. 900 ifpl=3andmb=1thenpr$="the milkbox is already open.":gosub2570
  87. 910 ifpl=3andmb=0thenmb=1:print"ok.":cm(7)=1
  88. 920 ifpl=6andmb=0thenpr$="the milkbox is already closed.":gosub2570
  89. 930 ifpl=6andmb=1thenmb=0:print"ok.":cm(7)=0
  90. 940 return
  91. 950 ifin(1)=1thenpr$="you already have the light.":gosub2570:return
  92. 960 iflt=1thenlt=0:in(1)=1:print"ok.":cm(9)=0:return
  93. 970 ifin(1)=0thenpr$="you do not have a light.":gosub2570:return
  94. 980 iflo=0thenprint"ok.":lo=1:return
  95. 990 iflo=1thenpr$="the light is already on.":gosub2570:return
  96. 1000 iflo=0thenpr$="the light is already off.":gosub2570:return
  97. 1010 iflo=1thenprint"ok.":lo=0:return
  98. 1020 print"[147]"ds$(16-fl(py,px))
  99. 1030 ec=px+1:dn$="east":ifec=11thengoto1050
  100. 1040 iffl(py,ec)<>0thengosub1120
  101. 1050 wc=px-1:dn$="west":ifwc=0thengoto1070
  102. 1060 iffl(py,wc)<>0thengosub1120
  103. 1070 nc=py-1:dn$="north":ifnc=0thengoto1090
  104. 1080 iffl(nc,px)<>0thengosub1120
  105. 1090 sc=py+1:dn$="south":ifsc=11thengoto1110
  106. 1100 iffl(sc,px)<>0thengosub1120
  107. 1110 return
  108. 1120 printdn$" is a doorway.":return
  109. 1130 ifgk=0andbk=0andrk=0thenprint"what key?":return
  110. 1140 print"ok."
  111. 1150 ifgkthengk=0:in(2)=1:return
  112. 1160 ifbkthenbk=0:in(3)=1:return
  113. 1170 ifrkthenrk=0:in(4)=1:bd=2:return
  114. 1180 return
  115. 1190 ifgd<>1then1220
  116. 1200 ifin(2)=0thenpr$=ds$(10):gosub2570:return
  117. 1210 ifin(2)=1thenpr$=ds$(27):gosub2570:ma=1:cm(11)=1:cm(1)=0:return
  118. 1220 ifbd<>1then1250
  119. 1230 ifin(3)=0thenpr$=ds$(10):gosub2570:return
  120. 1240 ifin(3)=1thenpr$=ds$(28):gosub2570:cm(8)=1:rk=1:cm(1)=0:return
  121. 1250 ifrd<>1then1280
  122. 1260 ifin(4)=0thenpr$=ds$(10):gosub2570:return
  123. 1270 ifin(4)=1thenprint"[147]":pr$=ds$(29):gosub2570:gosub2520
  124. 1280 return
  125. 1290 g=int(rnd(1)*lv*10)+1:pr$="you have found "+str$(g)+" gold pieces."
  126. 1300 gosub2570:gp=gp+g:pr$="you now have "+str$(gp)+" gold pieces.":gosub2570
  127. 1310 cm(10)=0:return
  128. 1320 op=int(rnd(1)*4)+1
  129. 1340 if(lv<=2)and(op>=3)then1320
  130. 1350 print"what is...";
  131. 1360 onopgoto1370,1400,1430,1460
  132. 1370 x=int(rnd(1)*lv*10):y=int(rnd(1)*lv*10)
  133. 1380 iflv>4thenx=x-int(rnd(1)*lv*5):y=y-int(rnd(1)*lv*5)
  134. 1390 z1=x+y:printx" + "y"?":inputz$:gosub1510:ifwr=2then1390
  135. 1395 return
  136. 1400 x=int(rnd(1)*lv*10):y=int(rnd(1)*lv*10)
  137. 1410 iflv<=3thenify>xthent=x:x=y:y=t
  138. 1420 z1=x-y:printx" - "y"?":inputz$:gosub1510:ifwr=2then1420
  139. 1425 return
  140. 1430 x=int(rnd(1)*lv*5):y=int(rnd(1)*lv*5)
  141. 1440 iflv>=4thenx=x-int(rnd(1)*lv*2):y=y-int(rnd(1)*lv*2)
  142. 1450 z1=x*y:printx" * "y"?":inputz$:gosub1510:ifwr=2then1450
  143. 1455 return
  144. 1460 x=int(rnd(1)*lv*5):y=int(rnd(1)*lv*5)
  145. 1470 iflv>=4thenx=x-int(rnd(1)*lv*3):y=y-int(rnd(1)*lv*3)
  146. 1480 ify=0theny=1
  147. 1490 z1=x/y:ifz1<>int(z1)then1460
  148. 1500 printx" / "y"?":inputz$
  149. 1505 gosub1510:ifwr=2then1490
  150. 1506 return
  151. 1510 ifval(z$)<>0thenz2=val(z$):goto1540
  152. 1520 ifz$<>"0"thenpr$="answer the question first!":gosub2570:wr=2:return
  153. 1530 z2=val(z$)
  154. 1540 ifz1=z2thenprint"[147]correct!!":wr=0:return
  155. 1550 print"[147]incorrect!!":wr=1:return
  156. 1560 wa=0:iflo=0thenpr$="i'd turn on my light first.":gosub2570:goto1610
  157. 1570 c=abs(pl=18)-abs(pl=19):d=abs(pl=17)-abs(pl=16):tx=px+c:ty=py+d
  158. 1580 iftx=11ortx=0orty=11orty=0thenprint"there is a wall there.":wa=1:goto1610
  159. 1590 iffl(ty,tx)=0thenprint"there is a wall there.":wa=1:goto1610
  160. 1600 px=tx:py=ty
  161. 1610 z=fl(py,px):return
  162. 1620 fori=1to10:forj=1to10:fl(i,j)=0:nextj:nexti
  163. 1625 nm=int(rnd(1)*10)+lv:i=1
  164. 1630 x=int(rnd(1)*10)+1:y=int(rnd(1)*10)+1:iffl(y,x)=3then1630
  165. 1640 fl(y,x)=3:i=i+1:ifi<=nmthen1630
  166. 1650 fori=1tonm*2
  167. 1660 x=int(rnd(1)*10)+1:y=int(rnd(1)*10)+1
  168. 1670 iffl(y,x)=3then1660
  169. 1680 fl(y,x)=0:nexti
  170. 1690 fori=1to10:forj=1to10
  171. 1700 iffl(i,j)=3thengosub1780
  172. 1710 nextj:nexti
  173. 1720 gosub1840:gx=x:gy=y:if(bx=xandby=y)or(rx=xandry=y)orfl(y,x)=0then1720
  174. 1730 gosub1840:bx=x:by=y:if(gx=xandgy=y)or(rx=xandry=y)orfl(y,x)=0then1730
  175. 1740 gosub1840:x1=x:y1=y:if(x2=xandy2=y)or(x3=xandy3=y)orfl(y,x)=0then1740
  176. 1750 gosub1840:x2=x:y2=y:if(x1=xandy1=y)or(x3=xandy3=y)orfl(y,x)=0then1750
  177. 1760 gosub1840:x3=x:y3=y:if(x1=xandy1=y)or(x2=xandy2=y)orfl(y,x)=0then1760
  178. 1770 return
  179. 1780 fork=jto10:gosub1800:nextk:fork=jto1step-1:gosub1800:nextk
  180. 1790 fork=ito10:gosub1820:nextk:fork=ito1step-1:gosub1820:nextk:return
  181. 1800 iffl(i,k)=0thenfl(i,k)=int(rnd(1)*2)+1
  182. 1810 return
  183. 1820 iffl(k,j)=0thenfl(k,j)=int(rnd(1)*2)+1
  184. 1830 return
  185. 1840 x=int(rnd(1)*10)+1:y=int(rnd(1)*10)+1:iffl(y,x)=0then1840
  186. 1850 return
  187. 1860 gosub790:fori=12to19:cm(i)=1:next:cm(22)=1
  188. 1870 print"[147]":pr$=ds$(16-z):gosub2570:iflo=1thengosub1030
  189. 1880 gosub2270:gosub2200
  190. 1890 gosub2310:ifpl=15andlothengosub1020:goto1880
  191. 1900 ifpl=20thengosub2850:goto1890
  192. 1910 ifpl=15andlo=0then1870
  193. 1920 ifpl=1thengosub1190:goto1890
  194. 1930 ifpl=14then1890
  195. 1940 ifpl=11thengosub2490:goto1890
  196. 1950 ifpl=8thengosub1130:goto1890
  197. 1960 ifpl=22thengosub2470:return
  198. 1970 ifpl>15thengosub1560:if(lo=0)or(wa=1)then1890
  199. 1980 return
  200. 2000 gosub790:fori=10to19:cm(i)=1:nexti:cm(22)=1
  201. 2010 pr$=ds$(23):gosub2570:pr$=ds$(24):gosub2570:gosub1320:ifwr=0thengoto2050
  202. 2020 gp=0:pr$=ds$(25):gosub2570:forw=1to2000:nextw
  203. 2030 x=int(rnd(1)*10+1):y=int(rnd(1)*10)+1:iffl(y,x)=0then2030
  204. 2040 px=x:py=y:z=fl(py,px):return
  205. 2050 pr$=ds$(26):gosub2570:fl(py,px)=2
  206. 2060 pr$=ds$(14):gosub2570:iflothengosub1030
  207. 2070 gosub2270:gosub2200
  208. 2080 gosub2310
  209. 2090 ifpl=20thengosub2850:goto2080
  210. 2100 ifpl=15andlothengosub1020:goto2070
  211. 2110 ifpl=15andlo=0then2060
  212. 2120 ifpl=14then2080
  213. 2130 ifpl=11then2490:goto2080
  214. 2140 ifpl=8thengosub1130:goto2080
  215. 2150 ifpl=1thengosub1190:goto2080
  216. 2160 ifpl=10thengosub1290:goto2080
  217. 2170 ifpl=22thengosub2470:return
  218. 2180 ifpl>15thengosub1560:if(lo=0)or(wa=1)then2080
  219. 2190 return
  220. 2200 if(x1=pxandy1=py)andgd<>2thenpr$=ds$(17):gosub2570:gd=1:cm(1)=1
  221. 2210 if(x2=pxandy2=py)andbd<>2thenpr$=ds$(19):gosub2570:bd=1:cm(1)=1
  222. 2220 if(x3=pxandy3=py)andrd<>2thenpr$=ds$(18):gosub2570:rd=1:cm(1)=1
  223. 2230 if(x1<>pxory1<>py)andgd<>2thengd=0
  224. 2240 if(x2<>pxory2<>py)andbd<>2thenbd=0
  225. 2250 if(x3<>pxory3<>py)andrd<>2thenrd=0
  226. 2260 return
  227. 2270 ifbx=pxandby=pyandin(3)=0thenpr$=ds$(21):gosub2570:bk=1:cm(8)=1
  228. 2280 ifgx=pxandgy=pyandin(2)=0thenpr$=ds$(20):gosub2570:gk=1:cm(8)=1
  229. 2290 ifrx=pxandry=pyandin(4)=0thenpr$=ds$(22):gosub2570:rk=1:cm(8)=1
  230. 2300 return
  231. 2310 inputc$:pl=0:fori=1to22:ifcm$(i)=c$thenpl=i:i=23
  232. 2320 next
  233. 2330 ifpl=0thenprint"you can't do that!":goto2310
  234. 2340 n$="":i=1
  235. 2350 t$=mid$(c$,i,1)
  236. 2360 ifasc(t$)=32thenl=i:goto2390
  237. 2370 ifi=len(c$)thengoto2410
  238. 2380 i=i+1:goto2350
  239. 2390 n$=mid$(c$,l+1,len(c$))
  240. 2400 ifcm(pl)=0thenprint"i see no "n$" here!":goto2310
  241. 2410 ifc$="inv"thengoto2430
  242. 2420 return
  243. 2430 print"you are carrying :"
  244. 2440 fori=1to5:ifin(i)=1thenprint"a "in$(i)
  245. 2450 nexti:ifgp<>0thenprintgp" gold pieces."
  246. 2460 return
  247. 2470 px=int(rnd(1)*10)+1:py=int(rnd(1)*10)+1:iffl(py,px)=0then2470
  248. 2480 z=fl(py,px):return
  249. 2490 ifin(5)=1thenpr$="you already have the map!":gosub2570:return
  250. 2500 ifma=0thenprint"what map?":return
  251. 2510 print"ok.":in(5)=1:ma=0:cm(20)=1:gd=2:return
  252. 2520 pr$="you have found your way out of the math dungeon.":gosub2570
  253. 2530 pr$="  you have won "+str$(gp)+" gold pieces in your journey.":gosub2570
  254. 2540 print" play again";:input a$
  255. 2550 ifa$="y"thenrun
  256. 2560 end
  257. 2570 iflen(pr$)<=ccthenprintpr$:return
  258. 2580 t$=mid$(pr$,cc,1):ifasc(t$)=32theni=cc:goto2620
  259. 2590 i=cc-1
  260. 2600 t$=mid$(pr$,i,1):ifasc(t$)=32thengoto2620
  261. 2610 i=i-1:goto2600
  262. 2620 a$=mid$(pr$,i+1,len(pr$)):b$=mid$(pr$,1,i-1):printb$
  263. 2630 iflen(a$)<=ccthenprinta$:return
  264. 2640 pr$=a$:goto2570
  265. 2650 dataopen door,open gate,open milkbox,close door,close gate,close milkbox
  266. 2660 dataget note,get key,get light,get gold,get map,light on,light off,inv
  267. 2670 datalook,n,s,e,w,map,map,algebra,light,green key,blue key,red key,map
  268. 2680 datayou are facing north. a gate is in front of you.,the gate is open.
  269. 2690 datathe gate is closed.,you are in a dense forest.
  270. 2700 datayou are in front of an old house. there is a milkbox by the door.
  271. 2710 datathe milkbox is closed.,the milkbox is open.,the door is closed.
  272. 2720 datathe door is open.,the door is locked. you do not have the right key.
  273. 2730 datathere is a note in the milkbox.,the door flies open with a bang!
  274. 2740 datathe note disappears and the milkbox closes.
  275. 2750 datayou are in a cold and damp room.,you are in a long and narrow hallway.
  276. 2760 datathere is an unlit light here.,there is a green door here.
  277. 2770 datathere is a red door here.,there is a blue door here.
  278. 2780 datathere is a green key here.,there is a blue key here.
  279. 2790 datathere is a red key here.,before you can get a good look at the area..
  280. 2800 dataa monster jumps out and says 'you must answer this question!
  281. 2810 data'now i'll take all your gold and transport you away!
  282. 2820 datathe monster disappears.                 you see some gold here!
  283. 2830 datathere is a map here!,there is a red key here!
  284. 2840 datathere is a sudden flash and you find yourself amidst some trees.
  285. 2850 ifin(5)=0thenprint"you don't have a map!":return
  286. 2860 print"[147]":print
  287. 2870 fori=1to10:tb=1:forj=1to10
  288. 2880 ifi=pyandj=pxthenprinttab(tb)"*";:goto2930
  289. 2890 iffl(i,j)=3thenprinttab(tb)"[144]m";:goto2930
  290. 2900 iffl(i,j)=2thenprinttab(tb)"r";:goto2930
  291. 2910 iffl(i,j)=1thenprinttab(tb)"[156]h";:goto2930
  292. 2920 printtab(tb)"[158] [146]";
  293. 2930 tb=tb+2:nextj:print:print:nexti
  294. 2940 print"":return
  295.